#include "TFT_eSPI.h"
#include "Animate.h"
#include "config.h"
#include "img/dog2.h"
#include "img/koushao.h"
#include "img/bring_love.h"
#include "img/bai_bring.h"

int Animate_key = -1; //初始化图标显示帧数
extern TFT_eSPI tft;

//
/**
 * @brief 根据提供的动画值和选择来播放动画。
 * 
 * @param Animate_value 一个指向 uint16_t 指针数组的指针，表示动画帧。
 * @param Animate_Choice 一个整数，表示动画的选择。
 */
void imgAnim(const uint16_t **Animate_value, int Animate_Choice)
{
    static int direction = 1; // 1 帧动画从前向后, -1 帧动画从后往前
    switch (Animate_Choice) {
        case 1:
            Animate_key++;
            if (Animate_key > 13) {
                Animate_key = 0;
            }
            *Animate_value = dog[Animate_key];
            break;
        case 2:
            if (direction == 1) {
                Animate_key++;
                if (Animate_key >= 5) {
                    Animate_key = 4;
                    direction = -1;
                }
            } else {
                Animate_key--;
                if (Animate_key <= 0) {
                    Animate_key = 1;
                    direction = 1;
                }
            }
            *Animate_value = koushao[Animate_key];
            break;
        case 3:
            Animate_key++;
            if (Animate_key > 10) {
                Animate_key = 0;
            }
            *Animate_value = bring_love[Animate_key];
            break;
        case 4:
            Animate_key++;
            if (Animate_key > 18) {
                Animate_key = 0;
            }
            *Animate_value = bai_bring[Animate_key];
            break;
        default:
            break;
    }
}

